package com.company.project.service.impl;

import com.company.project.dao.OrganizationMapper;
import com.company.project.model.Organization;
import com.company.project.service.OrganizationService;
import com.company.project.core.AbstractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


/**
 * Created by CodeGenerator on 2018/10/08.
 */
@Service
@Transactional
public class OrganizationServiceImpl extends AbstractService<Organization> implements OrganizationService {
    @Resource
    @Autowired
    private OrganizationMapper organizationMapper;


    public List<Organization> selectOrganization(){
        return organizationMapper.selectOrganization();
    }

    /**
     * 修改机构介绍
     * @return
     */
    @Override
    public Boolean updateOrganization(Organization organization) {
        List<Organization> organizations = this.selectOrganization();
        if (organizations.size()>0){
            Boolean aBoolean = organizationMapper.updateOrganization(organization);
            return aBoolean;
        }else {
            Boolean aBoolean = this.insertO(organization);
            return aBoolean;
        }

    }

    /**
     * 添加机构介绍
     * @param organization
     * @return
     */
    @Override
    public Boolean insertO(Organization organization) {
        Boolean aBoolean = organizationMapper.insertO(organization);
        return aBoolean;
    }

}
